<%@page import="com.j3l11234.myy_sign.entity.UserEntity"%>
<%@ page contentType="text/html;charset=utf-8"  language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<jsp:include page="../header.jsp" />

<jsp:include page="../navbar.jsp" />
	
<div class="container-fluid container-margin-top">
	<div class="row">
		<div class="col-lg-2 col-sm-3">
			<jsp:include page="sidebar.jsp" />
		</div>

		<div class="col-lg-10 col-sm-9">
			<div class="dialog dialog-danger">
				<h4>用户管理</h4>
				<div class="row">
					<form role="form">
						<div class="form-group col-sm-6 col-md-4">
							<label class="control-label">　　　　</label>
							<div class="control-content">
								<a href="<c:url value="/user/edit.do?user=0"/>" class="btn btn-danger btn-block" role="button">增加新用户</a>
							</div> 
						</div>   
					</form>
				</div>
			</div>

			<div class="dialog dialog-info">
				<div class="table-responsive">
					<table class="table table-hover table-deep text-left" style="margin-top: 20px;">
							<thead>
								<th>权限</th>
								<th>用户名</th>
								<th>昵称</th>
								<th>最后登录</th>
								<th></th>
							</thead>
							<tbody>
								<c:forEach items= "${userList}" var="user">
									<c:set var="user" value="${user}" scope="request"></c:set>
									<% 
									UserEntity user = (UserEntity)request.getAttribute("user");
									String privilege = "";
									if(UserEntity.checkPrivilege(user.getPrivilege(), UserEntity.Worker)){
										privilege += "员工/";
									}
									if(UserEntity.checkPrivilege(user.getPrivilege(), UserEntity.Manage)){
										privilege += "经理/";
									}
									if(UserEntity.checkPrivilege(user.getPrivilege(), UserEntity.Admin)){
										privilege += "管理员/";
									}
									request.setAttribute("privilege",privilege);
									%>
									<tr>
										<td><c:out value="${privilege}"/></td>
										<td><c:out value="${user.username}"/></td>
										<td><c:out value="${user.alias}"/></td>
										<td><fmt:formatDate value="${user.lastLogin}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
										<td><a href="<c:url value="/user/edit.do?user=${user.id}"/>" class="btn btn-info btn-xs" role="button">编辑</a></td>
									</tr>
								</c:forEach>
						</table>
					</div>
				</div>
			</div>       
		</div>
	</div>
</div>
<script>
	document.title = "系统信息-用户管理";
</script>

<jsp:include page="../footer.jsp" />

